home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / M / MUBBS / MUBBS Module Source V.5.cpt / Module Source / User Info Module / UserInfo.c < prev   
Encoding:
C/C++ Source or Header  |  1991-11-22  |  14.9 KB  |  431 lines  |  [TEXT/MSWD]

  1. /* *********************************************************************************
  2.      
  3.       MODULE:        UserInfo Module
  4.       
  5.      DESCRIPTION:    This UserInfo Module is a simple module for MUBBS, the
  6.                      Multi-User Bulliten Board System Software.
  7.                      
  8.      AUTHOR:        Noam Freedman
  9.      
  10.      Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
  11.  
  12.      This program source code and it's compiled version IS NOT IN THE
  13.      PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
  14.      regarding use of this program source code and it's compiled version.
  15.      
  16.      Revision History:
  17.      ============================================================
  18.      11/10/91 - Started programming
  19.      11/10/91 - Edited for release
  20.      ============================================================
  21.      
  22.  
  23.     ******************************************************************************** */
  24.  
  25. #define        INMAIN
  26.  
  27.  
  28. #include    "MUBBS Module.h"
  29. #include    <SetUpA4.h>
  30.  
  31. typedef struct PPP {
  32.             char passstring[260]; /* the string to pass to the module */
  33.             int field;   /* the field to get */
  34.             int uerror;   /* any errors found ? */
  35.             };
  36.  
  37. pascal void main (mode1,G1,P1)
  38.        int mode1;
  39.        struct GS *G1;
  40.        Ptr P1;  /* We aren't using this here */
  41. {
  42. Handle temph;
  43. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  44. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  45. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  46.  
  47. G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
  48. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  49.  
  50.  
  51. switch (mode[u]) { /* any un-handled modes return error from this module */
  52.     case 2:
  53.         dostuff();
  54.         G->moduleresult=0;
  55.         break;
  56.     case 98:
  57.         versionck(version); /* just return after this call, don't modify anything */
  58.         break;        
  59.     case 0:
  60.         strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
  61.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  62.         break;
  63.     default:
  64.         G->moduleresult=1; /* return bad code */
  65.     };
  66.  
  67. HUnlock(temph); /* unlocks this module, do this ! */
  68. RestoreA4(); /* call this when you are all done */
  69. }
  70.  
  71. checktime(warned) /* check if they are out of time yet */
  72. int warned;
  73. {
  74.  
  75. if(G->timeon[u] >= G->timeallowed[u]) {
  76.     send("]]YOUR TIME HAS EXPIRED, PLEASE CALL BACK TOMMOROW..]");
  77.     G->online[u]=FALSE; /* log them off now ! */
  78.     return TRUE;
  79.     }
  80. if(!warned && (G->timeon[u]+5) >= G->timeallowed[u]) {
  81.     send("]LOGOFF WARNING, YOU HAVE 5 MINUTES OF TIME LEFT !]");
  82.     return TRUE;
  83.     }
  84. return FALSE;
  85. }
  86.  
  87.  
  88. dostuff()
  89. {
  90.  
  91. struct PPP P;
  92. int i, warned;
  93. char    pass[40],
  94.         address[40],
  95.         city[40],
  96.         phone[40],
  97.         machine[40],
  98.         firston[40],
  99.         set1[40],
  100.         set2[40],
  101.         set3[40],
  102.         set4[40],
  103.         set5[40],
  104.         set6[40],
  105.         times[40],
  106.         minslast[40],
  107.         ups[40],
  108.         downs[40],
  109.         temp[40],
  110.         temp1[40],
  111.         temp2[40],
  112.         tempextra[40],
  113.         ch;
  114.  
  115.  
  116. if (!G->online[u]) { return; } /* do this check so we can log out if hang up */
  117.  
  118. loguser(G->modulename[u]); /* this tells where you are for remote sysop, or writes to log file */
  119.  
  120. /* you print the following so that the sysop can monitor use on the mac screen */
  121.  
  122. print("C> Line %d %s, at: %s\n",(u+1),G->username[u],G->modulename[u]);
  123.  
  124. send(G->CR[u]);
  125.  
  126.  
  127.  
  128. P.field = 3; /*  (users password) */
  129. module(3,"getuserfield",&P);
  130. strcpy(pass,P.passstring); /* move it so we can work with it */
  131. removespaces(pass); /* takes out trailing spaces */
  132.  
  133. P.field = 5; /*  (users address) */
  134. module(3,"getuserfield",&P);
  135. strcpy(address,P.passstring); /* move it so we can work with it */
  136. removespaces(address); /* takes out trailing spaces */
  137.  
  138. P.field = 6; /*  (users city) */
  139. module(3,"getuserfield",&P);
  140. strcpy(city,P.passstring); /* move it so we can work with it */
  141. removespaces(city); /* takes out trailing spaces */
  142.  
  143. P.field = 7; /*  (users phone) */
  144. module(3,"getuserfield",&P);
  145. strcpy(phone,P.passstring); /* move it so we can work with it */
  146. removespaces(phone); /* takes out trailing spaces */
  147.  
  148. P.field = 8; /*  (users machine) */
  149. module(3,"getuserfield",&P);
  150. strcpy(machine,P.passstring); /* move it so we can work with it */
  151. removespaces(machine); /* takes out trailing spaces */
  152.  
  153. P.field = 9; /*  (users firstlogon) */
  154. module(3,"getuserfield",&P);
  155. strcpy(firston,P.passstring); /* move it so we can work with it */
  156. removespaces(firston); /* takes out trailing spaces */
  157.  
  158. P.field = 10; /* (users settings) */
  159. module(3,"getuserfield",&P);
  160. strcpy(temp,P.passstring); /* move it so we can work with it */
  161. removespaces(temp); /* takes out trailing spaces */
  162. sscanf(temp,"%[^,],%[^,],%[^,],%[^,],%[^,],%s",
  163.         set1,set2,set3,set4,set5,set6);
  164.  
  165. P.field = 14; /* (users timeson) */
  166. module(3,"getuserfield",&P);
  167. strcpy(times,P.passstring); /* move it so we can work with it */
  168. removespaces(times); /* takes out trailing spaces */
  169.  
  170. P.field = 16; /* (users timeonlastlogon) */
  171. module(3,"getuserfield",&P);
  172. strcpy(temp,P.passstring); /* move it so we can work with it */
  173. removespaces(temp); /* takes out trailing spaces */
  174. sscanf(temp,"%[^,],%s",minslast,tempextra);
  175.  
  176. P.field = 17; /* (users up/down count) */
  177. module(3,"getuserfield",&P);
  178. strcpy(temp,P.passstring); /* move it so we can work with it */
  179. removespaces(temp); /* takes out trailing spaces */
  180. sscanf(temp,"%[^,],%[^,],%s",ups,downs,tempextra);
  181.  
  182.  
  183. displayinfo:
  184.  
  185. send("]]%s's Information]",G->username[u]);
  186. for( i = 1 ; i <= (strlen(G->username[u]) + 14);i++) send("-"); 
  187. send(G->CR[u]);
  188. send(G->CR[u]);
  189.  
  190. send("Name       : %-28s Accesslevel  : %i]",G->username[u],G->userpriv[u]);
  191. send("First on   : %-28s Last on      : %s]",firston,G->userlast[u]);
  192. send("Times on   : %-28s Time on last : %s]",times,minslast);
  193. send("Uploads    : %-28s Downloads    : %s]]",ups,downs);
  194.  
  195. send("        (you can change any item below)]]");
  196.  
  197. send("Password                       : %s]","<--- PRIVATE --->");
  198. send("Address                        : %s]",address);
  199. send("City, State, Zip               : %s]",city);
  200. send("Telephone number               : %s]",phone);
  201. send("Machine Type                   : %s]",machine);
  202. send(G->CR[u]);
  203.  
  204. if(strcmp(set1,"0")==0) strcpy(temp,"NO LIMIT");
  205. else strcpy(temp,set1);
  206. send("Number of lines per screen : %s]",temp);
  207.  
  208. if(strcmp(set2,"1")==0)      strcpy(temp,"ON");
  209. else if(strcmp(set2,"0")==0) strcpy(temp,"OFF");
  210. else                         strcpy(temp,set2);
  211. send("Flag: privacy              : %s]",temp);
  212.  
  213. if(strcmp(set3,"0")==0)      strcpy(temp,"ASCII");
  214. else if(strcmp(set3,"1")==0) strcpy(temp,"ANSI");
  215. else                         strcpy(temp,set3);
  216. send("Language                   : %s]",temp);
  217.  
  218. send("]>> (select a first letter from above), Quit : ");
  219.  
  220. if (!(cmd1(""))) {G->online[u]=FALSE; goto byebye;}
  221. warned=checktime(warned);
  222. if (!G->online[u]) goto byebye;
  223. ch = G->input[u];
  224. send(G->CR[u]);
  225. switch (ch)
  226.         {
  227.         case 'P':
  228.                 send("]]Enter your current password (Stars echo)   : ");
  229.                 passportsin(temp,30);
  230.                 send(G->CR[u]);
  231.                 if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  232.                                                   /* always check for online before continuing */
  233.                 strtoupper(temp); /* uppercase the password */
  234.                 if( strcmp(temp,pass) != 0 ) {send("]]Incorrect!!]]");goto displayinfo;break;}
  235.                 send("]You will now be asked for your new password, and then you must verify it.]]");
  236.                 send("]]Enter your new password (Stars echo)       : ");
  237.                 passportsin(temp,29);
  238.                 send(G->CR[u]);
  239.                 if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  240.                                                   /* always check for online before continuing */
  241.                 strtoupper(temp); /* uppercase the password */
  242.                 send("]]Enter your new password again (stars echo) : ");
  243.                 passportsin(tempextra,29);
  244.                 send(G->CR[u]);
  245.                 if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  246.                                                   /* always check for online before continuing */
  247.                 strtoupper(tempextra); /* uppercase the password */
  248.                 if( strcmp(temp,tempextra) != 0) {send("]]The two passwords do not match.]]");goto displayinfo;break;}
  249.                 if (strlen(temp) < 4) {send("]]Your password must be between 4 and 30 characters.]]");
  250.                                        goto displayinfo;break;}
  251.  
  252.                 P.field = 3; /*  (users address) */
  253.                 sprintf(P.passstring,"%-30s~\n",temp); /* make sure it's the correct length !! */
  254.                 module(3,"putuserfield",&P);
  255.                 P.field = 3;
  256.                 module(3,"getuserfield",&P);
  257.                 strcpy(pass,P.passstring); /* move it so we can work with it */
  258.                 removespaces(pass); /* takes out trailing spaces */
  259.                 
  260.                 goto displayinfo;
  261.                 break;                     
  262.     
  263.         case 'A':
  264.                 send("]]Your address is currently set to: %s]",address);
  265.                     {
  266.                     send("]]Enter your address: ");
  267.                     portsin(temp, 30);
  268.                     if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  269.                                                       /* always check for online before continuing */
  270.                     if (strcmp(temp,"")==0) {goto displayinfo;break;}
  271.                     send("]You typed in: \"%s\", is this correct (Y,N)? ",temp);
  272.                     if (!(cmd1(""))) {goto displayinfo;break;}
  273.                     ch = G->input[u];
  274.                     if ( ch != 'Y' && ch != 'y') {goto displayinfo;break;}
  275.                     P.field = 5; /*  (users address) */
  276.                     sprintf(P.passstring,"%-30s~\n",temp); /* make sure it's the correct length !! */
  277.                     module(3,"putuserfield",&P);
  278.                     P.field = 5;
  279.                     module(3,"getuserfield",&P);
  280.                     strcpy(address,P.passstring); /* move it so we can work with it */
  281.                     removespaces(address); /* takes out trailing spaces */
  282.                     }
  283.                 goto displayinfo;
  284.                 break;                     
  285.         case 'C':
  286.                 send("]]Your City, State, Zip is currently set to: %s]",city);
  287.                     {
  288.                     send("]]Enter your City, State, Zip: ");
  289.                     portsin(temp, 30);
  290.                     if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  291.                                                       /* always check for online before continuing */
  292.                     if (strcmp(temp,"")==0) {goto displayinfo;break;}
  293.                     send("]You typed in: \"%s\", is this correct (Y,N)? ",temp);
  294.                     if (!(cmd1(""))) {goto displayinfo;break;}
  295.                     ch = G->input[u];
  296.                     if ( ch != 'Y' && ch != 'y') {goto displayinfo;break;}
  297.                     P.field = 6; /*  (users city) */
  298.                     sprintf(P.passstring,"%-30s~\n",temp); /* make sure it's the correct length !! */
  299.                     module(3,"putuserfield",&P);
  300.                     P.field = 6;
  301.                     module(3,"getuserfield",&P);
  302.                     strcpy(city,P.passstring); /* move it so we can work with it */
  303.                     removespaces(city); /* takes out trailing spaces */
  304.                     }
  305.                 goto displayinfo;
  306.                 break;                     
  307.         case 'T':
  308.                 send("]]Your phone number is currently set to: %s]",phone);
  309.                     {
  310.                     send("]]Enter your phone number: ");
  311.                     portsin(temp, 30);
  312.                     if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  313.                                                       /* always check for online before continuing */
  314.                     if (strcmp(temp,"")==0) {goto displayinfo;break;}
  315.                     send("]You typed in: \"%s\", is this correct (Y,N)? ",temp);
  316.                     if (!(cmd1(""))) {goto displayinfo;break;}
  317.                     ch = G->input[u];
  318.                     if ( ch != 'Y' && ch != 'y') {goto displayinfo;break;}
  319.                     P.field = 7; /*  (users phone) */
  320.                     sprintf(P.passstring,"%-30s~\n",temp); /* make sure it's the correct length !! */
  321.                     module(3,"putuserfield",&P);
  322.                     P.field = 7;
  323.                     module(3,"getuserfield",&P);
  324.                     strcpy(phone,P.passstring); /* move it so we can work with it */
  325.                     removespaces(phone); /* takes out trailing spaces */
  326.                     }
  327.                 goto displayinfo;
  328.                 break;                     
  329.  
  330.         case 'M':
  331.                 send("]]Your computer is currently set to: %s]",machine);
  332.                     {
  333.                     send("]]Enter your type of computer: ");
  334.                     portsin(temp, 30);
  335.                     if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  336.                                                       /* always check for online before continuing */
  337.                     if (strcmp(temp,"")==0) {goto displayinfo;break;}
  338.                     send("]You typed in: \"%s\", is this correct (Y,N)? ",temp);
  339.                     if (!(cmd1(""))) {goto displayinfo;break;}
  340.                     ch = G->input[u];
  341.                     if ( ch != 'Y' && ch != 'y') {goto displayinfo;break;}
  342.                     P.field = 8; /*  (users computer) */
  343.                     sprintf(P.passstring,"%-30s~\n",temp); /* make sure it's the correct length !! */
  344.                     module(3,"putuserfield",&P);
  345.                     P.field = 8;
  346.                     module(3,"getuserfield",&P);
  347.                     strcpy(machine,P.passstring); /* move it so we can work with it */
  348.                     removespaces(machine); /* takes out trailing spaces */
  349.                     }
  350.                 goto displayinfo;
  351.                 break;                     
  352.         case 'N':
  353.                 send("]]Your current number of lines per screen is: %s]]",set1);
  354.                 send("To have MUBBS never pause, enter 0 for your choice.]");
  355.                     {
  356.                     send("]]Enter your choice : ");
  357.                     portsin(temp, 3);
  358.                     if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  359.                                                       /* always check for online before continuing */
  360.                     if (strcmp(temp,"")==0) {goto displayinfo;break;}
  361.                     i=strtoint(temp);
  362.                     if(i<=-1) {send("]]Incorrect choice.]]");goto displayinfo;break;}
  363.                     inttostr(i,set1);
  364.                     }                
  365.                 sprintf(temp,"%s,%s,%s,%s,%s,%s",set1,set2,set3,set4,set5,set6); /* Prepare the user name for compare */
  366.                 sprintf(P.passstring,"%-30s~\n",temp); /* make sure it's the correct length !! */
  367.                 P.field = 10; 
  368.                 module (3,"putuserfield",&P); /* int mode & module's name & pointer to the P struct */
  369.                 G->userlines[u]= i;
  370.                 goto displayinfo;
  371.                 break;
  372.  
  373.         case 'F':
  374.                 send("]]Privacy:  [0%c Off  [1%c On]]",']',']');
  375.                 send("Your current setting is: %s]]",set2);
  376.                     {
  377.                     send("]]Enter your choice : ");
  378.                     portsin(temp, 1);
  379.                     if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  380.                                                       /* always check for online before continuing */
  381.                     if (strcmp(temp,"")==0) {goto displayinfo;break;}
  382.                     if(temp[0] < '0') {send("]]Incorrect choice.]]");goto displayinfo;break;}
  383.                     if(temp[0] > '1') {send("]]Incorrect choice.]]");goto displayinfo;break;}
  384.                     strcpy(set2,temp);
  385.                     }                
  386.                 sprintf(temp,"%s,%s,%s,%s,%s,%s",set1,set2,set3,set4,set5,set6); /* Prepare the user name for compare */
  387.                 sprintf(P.passstring,"%-30s~\n",temp); /* make sure it's the correct length !! */
  388.                 P.field = 10; 
  389.                 module (3,"putuserfield",&P); /* int mode & module's name & pointer to the P struct */
  390.                 G->privacy[u]=strtoint(set2);
  391.                 goto displayinfo;
  392.                 break;
  393.  
  394.         case 'L':
  395.                 send("]]Language:  [0%c ASCII  [1%c ANSI]]",']',']');
  396.                 send("Your current setting is: %s]]",set3);
  397.                     {
  398.                     send("]]Enter your choice : ");
  399.                     portsin(temp, 1);
  400.                     if (! G->online[u]) goto byebye; /* portsin returns online for a time out */
  401.                                                       /* always check for online before continuing */
  402.                     if(temp[0] < '0') {send("]]Incorrect choice.]]");goto displayinfo;break;}
  403.                     if(temp[0] > '1') {send("]]Incorrect choice.]]");goto displayinfo;break;}
  404.                     strcpy(set3,temp);
  405.                     }                
  406.                 sprintf(temp,"%s,%s,%s,%s,%s,%s",set1,set2,set3,set4,set5,set6); /* Prepare the user name for compare */
  407.                 sprintf(P.passstring,"%-30s~\n",temp); /* make sure it's the correct length !! */
  408.                 P.field = 10; 
  409.                 module (3,"putuserfield",&P); /* int mode & module's name & pointer to the P struct */
  410.                 G->language[u]=strtoint(set3);
  411.                 goto displayinfo;
  412.                 break;
  413.         case 'Q':
  414.                 goto byebye;
  415.                 break;
  416.         default:
  417.                 goto displayinfo;
  418.                 break;
  419.         }
  420.         
  421.         
  422.         
  423.         
  424.         
  425. byebye:
  426. P.field=0;
  427. return;
  428.  
  429. }
  430.  
  431.